package com.binhthuan.catechist.server.bus;

import java.util.List;

import com.binhthuan.catechist.server.domain.AbstractObject;
import com.binhthuan.catechist.server.domain.Trainer;
import com.binhthuan.catechist.server.domain.Person;
import com.binhthuan.catechist.server.domain.Trainee;
import com.binhthuan.catechist.shared.constant.Parameter;

public class PersonBUS extends AbstractBUS {

    public Class<? extends Person> getPersonType(int statusType) {
        Class<? extends Person> cls = null;

        switch (statusType) {
        case Parameter.PersonType.TRAINEE_TYPE:
            cls = Trainee.class;
            break;
        case Parameter.PersonType.TRAINER_TYPE:
            cls = Trainer.class;
            break;
        }

        return cls;
    }

    public <T extends AbstractObject> T getPerson(int statusType, int id) {
        return get(getPersonType(statusType), id);
    }

    public <T extends AbstractObject> List<T> getAllPersons(int statusType) {
        return getAll(getPersonType(statusType));
    }
}
